package czk.concrent.createthread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CreateMethod3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask futureTask=new FutureTask(() -> {
            System.out.println(2);
            return 1;
        });
        Thread thread=new Thread(futureTask,"t1");
        thread.start();
        // 方法会阻塞，等待线程的返回结果
        Object o = futureTask.get();
        System.out.println(o);
    }

}
